package logic;

import data.IDestinationDAO;
import data.JDBCDestinationDAO;

public class Destination {
	
	private String id;
	private String name;
	private float profits;
	private int priority;
	private String continent;
	private static IDestinationDAO ddao = new JDBCDestinationDAO();
	private static String dest;
	
	public Destination(String id){
		IDestinationDAO ddao = new JDBCDestinationDAO();
		Destination d = ddao.select(id);
		if(d.getName() != null){
			this.id = d.getId();
			this.name = d.getName();
			this.profits = d.getProfits();
			this.priority = d.getPriority();
			this.continent = d.getContinent();
		}else{
			this.name = "Destino no establecido";
			this.profits = 0;
			this.priority = 10;
		}
	}
	
	public Destination(String id, String name, int priority, String continent) {
		super();
		this.id = id;
		this.name = name;
		this.profits = 0;
		this.priority = priority;
		this.continent = continent;
		
	}
	

	public Destination() {
		super();
	}
	
	public static synchronized String getRandomInstance(){
		if(dest == null){
			dest = RandomDest();
		}
		return dest;
	}
	public static String RandomDest(){
		String dest = ddao.selectRandomDest();
		return dest;
	}

	public String getName() {
		return name;
	}

	public void setNombre(String name) {
		this.name = name;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public float getProfits() {
		return profits;
	}
	public void setProfits(float profits) {
		this.profits = profits;
	}
	
	public String toString() {
		return "Destination [id=" + id + ", name=" + name + ", profits="
				+ profits + ", continent=" + continent + "]";
	}


	public void setPriority(int priority) {
		this.priority = priority;
	}


	public int getPriority() {
		return priority;
	}

	public String getContinent(){
		return continent;
	}
	
	public void setContinent(String continent){
		this.continent = continent;
	}
	

}
